// function Stack() {
//   this.items = []
//   Stack.prototype.push = function() {
//     Array.from(arguments).forEach(item => {
//       if (item instanceof Array) {
//         this.push(...item)
//       } else {
//         this.items[this.items.length] = item
//       }
//     })
//   }
// }
// let s = new Stack()
// console.log(s.items);
// s.push(1, 2, 3, 4, 5, [6, 7, 8, [9, 10]])

function htmlEscape(text) {
  return text.replace(/[<>"&]/g, function(match, pos, originalText) {
    switch (match) {
      case "<":
        return "&lt;";
      case ">":
        return "&gt;";
      case "&":
        return "&amp;";
      case "\"":
        return "&quot;";
    }
  });
}
console.log(htmlEscape("<p class=\"greeting\">Hello world!</p>"));
// "&lt;p class=&quot;greeting&quot;&gt;Hello world!</p>"